package aconcagua.measure

class ProportionalDerivedUnit extends DerivedUnit {
	private nameForOne;
	private nameForMany;
	private sign;
	private baseUnit;
	private conversionFactor;
	
	// (class) instance creation
	public ProportionalDerivedUnit(aBaseUnit, aConversionFactor, aName) {
		baseUnit = aBaseUnit;
		conversionFactor = aConversionFactor;
		nameForOne = aName;
		nameForMany = nameForManyFrom(aName);
		sign = defaultSign();
	}
	
	public ProportionalDerivedUnit(aBaseUnit, aConversionFactor, aName, aSign) {
		baseUnit = aBaseUnit;
		conversionFactor = aConversionFactor;
		nameForOne = aName;
		nameForMany = nameForManyFrom(aName);
		sign = aSign;
	}
	
	public ProportionalDerivedUnit(aBaseUnit, aConversionFactor, aNameForOne, aNameForMany, aSign) {
		baseUnit = aBaseUnit;
		conversionFactor = aConversionFactor;
		nameForOne = aNameForOne;
		nameForMany = aNameForMany;
		sign = aSign;
	}
	
	// accessing
	@Override
	public baseUnit() {
		return baseUnit;
	}
	
	public conversionFactor() {
		return conversionFactor;
	}
	
	@Override
	public nameForMany() {
		return nameForMany;
	}
	
	@Override
	public nameForOne() {
		return nameForOne;
	}
	
	@Override
	public sign() {
		return sign;
	}
	
	// converting
	@Override
	public convertAmountToBaseUnit(aNumber) {
		return aNumber * conversionFactor;
	}
	
	// converting - private
	@Override
	protected convertAmountFromBaseUnit(aNumber) {
		return aNumber / conversionFactor;
	}
}
